﻿using DreamSpace.Net.ScriptEngines;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using V8.Net;

namespace DreamSpace.Net
{
    public partial interface IServerHost<out TScriptEngine>
    {
        /// <summary>
        /// Writes a message to the console (uses the standard output stream).
        /// </summary>
        /// <param name="message">The message to write to the console.</param>
        void Write(string message);

        /// <summary>
        /// Writes a message to the console with line termination (uses the standard output stream).
        /// </summary>
        /// <param name="message">The message to write to the console.</param>
        void WriteLine(string message);
    }

    public partial class ServerHost<TScriptEngine> // This class part holds the JavaScript environment function mappings.
    {
        /// <summary>
        /// Writes a message to the console (uses the standard output stream).
        /// </summary>
        /// <param name="message">The message to write to the console.</param>
        [ScriptMember("write")]
        public void Write(string message)
        {
            if (Console.Out != null)
                Console.Write(message);
        }

        /// <summary>
        /// Writes a message to the console with line termination (uses the standard output stream).
        /// </summary>
        /// <param name="message">The message to write to the console.</param>
        [ScriptMember("writeln")]
        public void WriteLine(string message)
        {
            if (Console.Out != null)
                Console.WriteLine(message);
        }
    }
}
